package com.wicket.okrbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrbff.biz.service.EvaThemeService;
import com.wicket.okrbff.biz.service.dto.req.*;
import com.wicket.okrbff.biz.service.dto.res.*;
import com.wicket.okrbff.common.ro.OkrResult;
import com.wicket.okrbff.common.ro.OkrResult;
import com.wicket.okrbff.common.util.CommonFunctionHelper;
import com.wicket.okrbff.common.util.RedisUtil;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrapp.integration.FwAppEvaThemeClient;
import com.wicket.okrapp.integration.dto.AddEvaTempRespDto;
import com.wicket.okrapp.integration.dto.AddEvaTempReqDto;
import com.wicket.okrbff.common.exception.Assert;
import com.wicket.okrapp.integration.dto.AddEvaPortraitRelatedRespDto;
import com.wicket.okrapp.integration.dto.AddEvaPortraitRelatedReqDto;
import com.wicket.okrapp.integration.dto.BusAppDocRelaDto;
import java.util.stream.Collectors;
import com.wicket.okrapp.integration.dto.QueryAddEvaTempJudgeDetailRespDto;
import com.wicket.okrapp.integration.dto.QueryAddEvaTempJudgeDetailReqDto;
import com.wicket.okrapp.integration.dto.BackToFirstStepEvaTempRespDto;
import com.wicket.okrapp.integration.dto.BackToFirstStepEvaTempReqDto;
import com.wicket.okrapp.integration.dto.ImplementMidManualSetCompletRespDto;
import com.wicket.okrapp.integration.dto.ImplementMidManualSetCompletReqDto;
import com.wicket.okrapp.integration.dto.QueryEvaTempPresentIsSuperMgtStateDetailRespDto;
import com.wicket.okrapp.integration.dto.QueryEvaTempPresentIsSuperMgtStateDetailReqDto;
import com.wicket.okrapp.integration.dto.ImplementEvaTempAddTermJudgeComRespDto;
import com.wicket.okrapp.integration.dto.ImplementEvaTempAddTermJudgeComReqDto;
import com.wicket.okrbff.common.exception.BizException;
import cn.hutool.core.collection.CollectionUtil;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class EvaThemeServiceImpl implements EvaThemeService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  FwAppEvaThemeClient fwAppEvaThemeClient;
/**
   * B3-2新增评价模板(管理)[3123]
   * gen by moon at 7/1/2024, 6:48:07 PM
   */
    @Trace(operationName = "B3-2新增评价模板(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffAddEvaTempRespDto addEvaTemp(BffAddEvaTempReqDto reqDto){
      
       
       AddEvaTempRespDto addEvaTempRespDto_1 =null;
//步骤0: D3-2新增评价模板 - addEvaTemp
     AddEvaTempRespDto addEvaTempRespDto = null;
    AddEvaTempReqDto addEvaTempReqDto=new AddEvaTempReqDto();
  if(reqDto!=null){
      addEvaTempReqDto.setEvaluationSubjectId(reqDto.getEvaluationSubjectId());//SimpleFieldAssign//sourceId:160639_1
addEvaTempReqDto.setConfSchemeCode(reqDto.getConfSchemeCode());//SimpleFieldAssign//sourceId:335480_1
addEvaTempReqDto.setEvaluationTempNumber(reqDto.getEvaluationTempNumber());//SimpleFieldAssign//sourceId:108826_1
addEvaTempReqDto.setEvaluationTempName(reqDto.getEvaluationTempName());//SimpleFieldAssign//sourceId:108827_1
addEvaTempReqDto.setEvaluationTempShortName(reqDto.getEvaluationTempShortName());//SimpleFieldAssign//sourceId:108828_1
addEvaTempReqDto.setDeptId(reqDto.getDeptId());//SimpleFieldAssign//sourceId:108830_1
addEvaTempReqDto.setHypertextContent(reqDto.getHypertextContent());//SimpleFieldAssign//sourceId:1914408_1
    }
  
    /*D3-2新增评价模板[3100]   */
    Assert.isNull(addEvaTempReqDto.getEvaluationSubjectId(),"B3-2新增评价模板(管理)-D3-2新增评价模板-归属评价主题ID不能为空",false);
Assert.isNull(addEvaTempReqDto.getConfSchemeCode(),"B3-2新增评价模板(管理)-D3-2新增评价模板-配置方案标识不能为空",false);
Assert.isNull(addEvaTempReqDto.getEvaluationTempNumber(),"B3-2新增评价模板(管理)-D3-2新增评价模板-评价模板编号不能为空",false);
Assert.isNull(addEvaTempReqDto.getEvaluationTempName(),"B3-2新增评价模板(管理)-D3-2新增评价模板-评价模板名称不能为空",false);
Assert.isNull(addEvaTempReqDto.getEvaluationTempShortName(),"B3-2新增评价模板(管理)-D3-2新增评价模板-评价模板简称不能为空",false);
Assert.isNull(addEvaTempReqDto.getDeptId(),"B3-2新增评价模板(管理)-D3-2新增评价模板-牵头部门ID不能为空",false);
Assert.isNull(addEvaTempReqDto.getHypertextContent(),"B3-2新增评价模板(管理)-D3-2新增评价模板-超文本内容不能为空",false);
      addEvaTempRespDto = fwAppEvaThemeClient.addEvaTemp(addEvaTempReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      addEvaTempRespDto_1 = addEvaTempRespDto;
    
BffAddEvaTempRespDto retData = new BffAddEvaTempRespDto();
  if(addEvaTempRespDto_1!=null){
      retData.setEvaluationTemplateId(addEvaTempRespDto_1.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:108842_1
retData.setBatchId(addEvaTempRespDto_1.getBatchId());//SimpleFieldAssign//sourceId:322704_1
retData.setBatchCode(addEvaTempRespDto_1.getBatchCode());//SimpleFieldAssign//sourceId:322817_1
retData.setTargetId(addEvaTempRespDto_1.getTargetId());//SimpleFieldAssign//sourceId:108844_1
retData.setEndValue(addEvaTempRespDto_1.getEndValue());//SimpleFieldAssign//sourceId:939293_1
    }
  

  
  
return retData;
  }
/**
   * B3-2新增评价画像相关(管理)[3122]
   * gen by moon at 6/9/2023, 6:28:12 AM
   */
    @Trace(operationName = "B3-2新增评价画像相关(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffAddEvaPortraitRelatedRespDto addEvaPortraitRelated(BffAddEvaPortraitRelatedReqDto reqDto){
      
       
       AddEvaPortraitRelatedRespDto addEvaPortraitRelatedRespDto_1 =null;
//步骤0: D3-2新增评价画像相关 - addEvaPortraitRelated
     AddEvaPortraitRelatedRespDto addEvaPortraitRelatedRespDto = null;
    AddEvaPortraitRelatedReqDto addEvaPortraitRelatedReqDto=new AddEvaPortraitRelatedReqDto();
  if(reqDto!=null){
      addEvaPortraitRelatedReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:108790_1
addEvaPortraitRelatedReqDto.setCycleStartTime(reqDto.getCycleStartTime());//SimpleFieldAssign//sourceId:1026863_1
    }
  
    /*D3-2新增评价画像相关[3112]   */
    Assert.isNull(addEvaPortraitRelatedReqDto.getEvaluationTemplateId(),"B3-2新增评价画像相关(管理)-D3-2新增评价画像相关-评价模板ID不能为空",false);
Assert.isNull(addEvaPortraitRelatedReqDto.getCycleStartTime(),"B3-2新增评价画像相关(管理)-D3-2新增评价画像相关-目标计划开始时间不能为空",false);
      addEvaPortraitRelatedRespDto = fwAppEvaThemeClient.addEvaPortraitRelated(addEvaPortraitRelatedReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      addEvaPortraitRelatedRespDto_1 = addEvaPortraitRelatedRespDto;
    
BffAddEvaPortraitRelatedRespDto retData = new BffAddEvaPortraitRelatedRespDto();
  if(addEvaPortraitRelatedRespDto_1!=null){
      retData.setEvaluationPortraitId(addEvaPortraitRelatedRespDto_1.getEvaluationPortraitId());//SimpleFieldAssign//sourceId:376037_1
retData.setEvaluationObjectId(addEvaPortraitRelatedRespDto_1.getEvaluationObjectId());//SimpleFieldAssign//sourceId:108806_1
retData.setEvaluationFillRoleId(addEvaPortraitRelatedRespDto_1.getEvaluationFillRoleId());//SimpleFieldAssign//sourceId:376042_1
retData.setVirtualOrgId(addEvaPortraitRelatedRespDto_1.getVirtualOrgId());//SimpleFieldAssign//sourceId:108802_1
retData.setVirtualOrgMemberDeptId(addEvaPortraitRelatedRespDto_1.getVirtualOrgMemberDeptId());//SimpleFieldAssign//sourceId:108803_1
retData.setVirtualOrgMemberId(addEvaPortraitRelatedRespDto_1.getVirtualOrgMemberId());//SimpleFieldAssign//sourceId:108804_1
    }
  

  
  
return retData;
  }
/**
   * B3-3新增评价模板判断(管理)[4499]
   * gen by moon at 5/6/2023, 3:11:13 PM
   */
    @Trace(operationName = "B3-3新增评价模板判断(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryAddEvaTempJudgeDetailRespDto queryAddEvaTempJudgeDetail(BffQueryAddEvaTempJudgeDetailReqDto reqDto){
      
       
       QueryAddEvaTempJudgeDetailRespDto queryAddEvaTempJudgeDetailRespDto_1 =null;
//步骤0: D3-3新增评价模板判断 - queryAddEvaTempJudgeDetail
     QueryAddEvaTempJudgeDetailRespDto queryAddEvaTempJudgeDetailRespDto = null;
    QueryAddEvaTempJudgeDetailReqDto queryAddEvaTempJudgeDetailReqDto=new QueryAddEvaTempJudgeDetailReqDto();
  if(reqDto!=null){
      queryAddEvaTempJudgeDetailReqDto.setPrivacyCode(reqDto.getPrivacyCode());//SimpleFieldAssign//sourceId:322922_1
queryAddEvaTempJudgeDetailReqDto.setConfSchemeCode(reqDto.getConfSchemeCode());//SimpleFieldAssign//sourceId:333771_1
    }
  
    /*D3-3新增评价模板判断[4500]   */
    Assert.isNull(queryAddEvaTempJudgeDetailReqDto.getPrivacyCode(),"B3-3新增评价模板判断(管理)-D3-3新增评价模板判断-权限标识不能为空",false);
Assert.isNull(queryAddEvaTempJudgeDetailReqDto.getConfSchemeCode(),"B3-3新增评价模板判断(管理)-D3-3新增评价模板判断-配置方案标识不能为空",false);
      queryAddEvaTempJudgeDetailRespDto = fwAppEvaThemeClient.queryAddEvaTempJudgeDetail(queryAddEvaTempJudgeDetailReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      queryAddEvaTempJudgeDetailRespDto_1 = queryAddEvaTempJudgeDetailRespDto;
    
BffQueryAddEvaTempJudgeDetailRespDto retData = new BffQueryAddEvaTempJudgeDetailRespDto();
  if(queryAddEvaTempJudgeDetailRespDto_1!=null){
      retData.setIsVisible(queryAddEvaTempJudgeDetailRespDto_1.getIsVisible());//SimpleFieldAssign//sourceId:506746_1
retData.setIsUsable(queryAddEvaTempJudgeDetailRespDto_1.getIsUsable());//SimpleFieldAssign//sourceId:506747_1
      retData.setEndValue(queryAddEvaTempJudgeDetailRespDto_1.getEndValue());//SimpleFieldAssign//sourceId:333796_1
    }
  

  
  
return retData;
  }
/**
   * B3-3返回新增评价模板第一步[4585]
   * gen by moon at 10/17/2022, 10:42:29 AM
   */
    @Trace(operationName = "B3-3返回新增评价模板第一步")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffBackToFirstStepEvaTempRespDto backToFirstStepEvaTemp(BffBackToFirstStepEvaTempReqDto reqDto){
      
       
       //步骤0: D3-3返回评价模板第一步 - backToFirstStepEvaTemp
     BackToFirstStepEvaTempRespDto backToFirstStepEvaTempRespDto = null;
    BackToFirstStepEvaTempReqDto backToFirstStepEvaTempReqDto=new BackToFirstStepEvaTempReqDto();
  if(reqDto!=null){
      backToFirstStepEvaTempReqDto.setEvaluationSubjectId(reqDto.getEvaluationSubjectId());//SimpleFieldAssign//sourceId:334522_1
    }
  
    /*D3-3返回评价模板第一步[4609]   */
    Assert.isNull(backToFirstStepEvaTempReqDto.getEvaluationSubjectId(),"B3-3返回新增评价模板第一步-D3-3返回评价模板第一步-归属评价主题ID不能为空",false);
      backToFirstStepEvaTempRespDto = fwAppEvaThemeClient.backToFirstStepEvaTemp(backToFirstStepEvaTempReqDto).getData();
      
      
      
    
BffBackToFirstStepEvaTempRespDto retData = new BffBackToFirstStepEvaTempRespDto();
  
  

  
  
return retData;
  }
/**
   * B3执行高层人工设置完成(管理)[5543]
   * gen by moon at 12/29/2022, 9:53:14 PM
   */
    @Trace(operationName = "B3执行高层人工设置完成(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffImplementMidManualSetCompletRespDto implementMidManualSetComplet(BffImplementMidManualSetCompletReqDto reqDto){


       //步骤0: D3执行高层人工设置完成 - implementMidManualSetComplet
     ImplementMidManualSetCompletRespDto implementMidManualSetCompletRespDto = null;
    ImplementMidManualSetCompletReqDto implementMidManualSetCompletReqDto=new ImplementMidManualSetCompletReqDto();
  if(reqDto!=null){
      implementMidManualSetCompletReqDto.setTargetId(reqDto.getTargetId());//SimpleFieldAssign//sourceId:552057_1
implementMidManualSetCompletReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:552058_1
implementMidManualSetCompletReqDto.setSetCompleteStatus(reqDto.getSetCompleteStatus());//SimpleFieldAssign//sourceId:552059_1
    }

    /*D3执行高层人工设置完成[5542]   */
    Assert.isNull(implementMidManualSetCompletReqDto.getTargetId(),"B3执行高层人工设置完成(管理)-D3执行高层人工设置完成-目标ID不能为空",false);
Assert.isNull(implementMidManualSetCompletReqDto.getEvaluationTemplateId(),"B3执行高层人工设置完成(管理)-D3执行高层人工设置完成-评价模板ID不能为空",false);
Assert.isNull(implementMidManualSetCompletReqDto.getSetCompleteStatus(),"B3执行高层人工设置完成(管理)-D3执行高层人工设置完成-设置完成状态不能为空",false);
      implementMidManualSetCompletRespDto = fwAppEvaThemeClient.implementMidManualSetComplet(implementMidManualSetCompletReqDto).getData();




BffImplementMidManualSetCompletRespDto retData = new BffImplementMidManualSetCompletRespDto();





return retData;
  }
/**
   * B3-3查询评价模板当前特权管理状态(管理)[5859]
   * gen by moon at 2/6/2023, 7:30:53 PM
   */
    @Trace(operationName = "B3-3查询评价模板当前特权管理状态(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffQueryEvaTempPresentIsSuperMgtStateDetailRespDto queryEvaTempPresentIsSuperMgtStateDetail(BffQueryEvaTempPresentIsSuperMgtStateDetailReqDto reqDto){


       QueryEvaTempPresentIsSuperMgtStateDetailRespDto queryEvaTempPresentIsSuperMgtStateDetailRespDto_1 =null;
//步骤0: D3查询评价模板当前特权管理状态 - queryEvaTempPresentIsSuperMgtStateDetail
     QueryEvaTempPresentIsSuperMgtStateDetailRespDto queryEvaTempPresentIsSuperMgtStateDetailRespDto = null;
    QueryEvaTempPresentIsSuperMgtStateDetailReqDto queryEvaTempPresentIsSuperMgtStateDetailReqDto=new QueryEvaTempPresentIsSuperMgtStateDetailReqDto();
  if(reqDto!=null){
      queryEvaTempPresentIsSuperMgtStateDetailReqDto.setBatchOperateScene(reqDto.getBatchOperateScene());//SimpleFieldAssign//sourceId:655336_1
queryEvaTempPresentIsSuperMgtStateDetailReqDto.setBatchSetId(reqDto.getBatchSetId());//SimpleFieldAssign//sourceId:655337_1
    }

    /*D3查询评价模板当前特权管理状态[5856]   */
    Assert.isNull(queryEvaTempPresentIsSuperMgtStateDetailReqDto.getBatchOperateScene(),"B3-3查询评价模板当前特权管理状态(管理)-D3查询评价模板当前特权管理状态-高/中/基层操作场景不能为空",false);
Assert.isNull(queryEvaTempPresentIsSuperMgtStateDetailReqDto.getBatchSetId(),"B3-3查询评价模板当前特权管理状态(管理)-D3查询评价模板当前特权管理状态-评价模板ID/部门目标任务书ID/部门OKR目标ID不能为空",false);
      queryEvaTempPresentIsSuperMgtStateDetailRespDto = fwAppEvaThemeClient.queryEvaTempPresentIsSuperMgtStateDetail(queryEvaTempPresentIsSuperMgtStateDetailReqDto).getData();


      queryEvaTempPresentIsSuperMgtStateDetailRespDto_1 = queryEvaTempPresentIsSuperMgtStateDetailRespDto;

BffQueryEvaTempPresentIsSuperMgtStateDetailRespDto retData = new BffQueryEvaTempPresentIsSuperMgtStateDetailRespDto();
  if(queryEvaTempPresentIsSuperMgtStateDetailRespDto_1!=null){
      retData.setMgtType(queryEvaTempPresentIsSuperMgtStateDetailRespDto_1.getMgtType());//SimpleFieldAssign//sourceId:655342_1
retData.setIsSuperMgt(queryEvaTempPresentIsSuperMgtStateDetailRespDto_1.getIsSuperMgt());//SimpleFieldAssign//sourceId:655343_1
    }




return retData;
  }
/**
   * B3执行评价模板新增条件判断(管理)[6486]
   * gen by moon at 5/6/2023, 3:11:20 PM
   */
    @Trace(operationName = "B3执行评价模板新增条件判断(管理)")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffImplementEvaTempAddTermJudgeRespDto implementEvaTempAddTermJudge(BffImplementEvaTempAddTermJudgeReqDto reqDto){


       //virtualUsage D3执行评价模板新增条件判断(公共)  39971
      ImplementEvaTempAddTermJudgeComRespDto implementEvaTempAddTermJudgeComRespDto = null;
    ImplementEvaTempAddTermJudgeComReqDto implementEvaTempAddTermJudgeComReqDto=new ImplementEvaTempAddTermJudgeComReqDto();
  if(reqDto!=null){
      implementEvaTempAddTermJudgeComReqDto.setEvaluationSubjectId(reqDto.getEvaluationSubjectId());//SimpleFieldAssign//sourceId:896480_1_39971
    }

    /*D3执行评价模板新增条件判断(公共)[6410]   */
    Assert.isNull(implementEvaTempAddTermJudgeComReqDto.getEvaluationSubjectId(),"B3执行评价模板新增条件判断(管理)-D3执行评价模板新增条件判断(公共)-评价主题ID不能为空",false);
      implementEvaTempAddTermJudgeComRespDto = fwAppEvaThemeClient.implementEvaTempAddTermJudgeCom(implementEvaTempAddTermJudgeComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;



if((implementEvaTempAddTermJudgeComRespDto!= null&&  implementEvaTempAddTermJudgeComRespDto.getIsAddEvaTemp() !=null && implementEvaTempAddTermJudgeComRespDto.getIsAddEvaTemp().equals("0"))) {
        //if(D3执行评价模板新增条件判断(公共).是否允许新增评价模板 等于 0)  39972

//异常结束 39973
      throw new BizException("330000222","对不起！当前有正在新增的评价模板，请联系管理员或稍后再试~",false);
      }
BffImplementEvaTempAddTermJudgeRespDto retData = new BffImplementEvaTempAddTermJudgeRespDto();





return retData;
  }
  //
}
